home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d899.lha / GoodDouble / sources / GoodDouble.c < prev    next >
C/C++ Source or Header  |  1993-07-05  |  2KB  |  90 lines

  1. /*
  2.  *        GoodDouble.c
  3.  *
  4.  *        by Piotr Obminski
  5.  *
  6.  *        July 1993
  7.  *
  8.  *        version 0.3
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <intuition/intuition.h>
  13.  
  14. #include "good_double.h"    /* only needed because of #define GDC_REGARGS */
  15.  
  16.  
  17. #define left_button     0L
  18. #define middle_button   1L
  19. #define right_button    2L
  20.  
  21.  
  22. /* ------------------------------------------------------------------
  23.  * returns TRUE if the time you give it was inside the double-click
  24.  * time-distance from the last time it got; and NO OTHER MOUSE BUTTON
  25.  * WAS CLICKED IN BETWEEN. Otherwise return FALSE.
  26.  *
  27.  * This one understands all three mouse-buttons (the MIDDLE one too)
  28.  * ------------------------------------------------------------------ */
  29.  
  30. #ifdef GDC_REGARGS
  31.     #ifdef _DCC                    /* i.e. DICE */
  32.             __regargs
  33.     #endif
  34. #endif
  35.         BOOL
  36.     GoodDouble( button, secs, mics )
  37. #ifdef GDC_REGARGS
  38.         register LONG button;
  39.         register ULONG secs, mics;
  40. #else
  41.         LONG button;
  42.         ULONG secs, mics;
  43. #endif
  44. {
  45.     static ULONG OldLSeconds    = 0L;
  46.     static ULONG OldLMicros     = 0L;
  47.  
  48.     static ULONG OldMSeconds    = 0L;
  49.     static ULONG OldMMicros     = 0L;
  50.  
  51.     static ULONG OldRSeconds    = 0L;
  52.     static ULONG OldRMicros     = 0L;
  53.  
  54.     register BOOL ret_val = FALSE;
  55.  
  56.     switch ( button ) {
  57.         case left_button:
  58.             if ( DoubleClick( OldLSeconds, OldLMicros, secs, mics ) ) {
  59.                 OldLSeconds = OldLMicros = 0L;
  60.                 ret_val = TRUE;
  61.             } else {
  62.                 OldLSeconds = secs;
  63.                 OldLMicros  = mics;
  64.             }
  65.             OldMSeconds = OldMMicros = OldRSeconds = OldRMicros = 0L;
  66.             break;
  67.         case middle_button:
  68.             if ( DoubleClick( OldMSeconds, OldMMicros, secs, mics ) ) {
  69.                 OldMSeconds = OldMMicros = 0L;
  70.                 ret_val = TRUE;
  71.             } else {
  72.                 OldMSeconds = secs;
  73.                 OldMMicros  = mics;
  74.             }
  75.             OldLSeconds = OldLMicros = OldRSeconds = OldRMicros = 0L;
  76.             break;
  77.         case right_button:
  78.             if ( DoubleClick( OldRSeconds, OldRMicros, secs, mics ) ) {
  79.                 OldRSeconds = OldRMicros = 0L;
  80.                 ret_val = TRUE;
  81.             } else {
  82.                 OldRSeconds = secs;
  83.                 OldRMicros  = mics;
  84.             }
  85.             OldLSeconds = OldLMicros = OldMSeconds = OldMMicros = 0L;
  86.             break;
  87.     }
  88.     return( ret_val );
  89. }
  90.